class Solution:
    def canJump(self, nums: list[int]) -> bool:

        now_index = 0
        next_index = 1
        maxPos = 0
        status = True
        while status:
            status = False
            # 找到 next_index + nums[next_index]  最大的点 代表跳到这个点能跳到最远的距离
            for distance in range(1,nums[now_index]+1):
                # next_index = now_index + dis
                if now_index + distance < len(nums) and now_index+distance+nums[now_index+distance] > maxPos:
                    status = True
                    next_index = now_index + distance
                    maxPos = next_index + nums[next_index]
                    if maxPos >= len(nums)-1:
                        return True
            now_index = next_index
        return False
                    

s = Solution()
result = s.canJump([1,1,1,0])
print(result)